-- By ScatmanJosh --

-- Variables --
XEN = XEN or {}

-- Functions --
function XEN.FindBySID( sid )
	for k,v in pairs( player.GetAll() ) do
		if sid == v:SteamID() then
			return v, v:Nick()
		end
	end
	return nil, 0
end

function XEN.FindByUID( uid )
	for k,v in pairs( player.GetAll() ) do
		if uid == v:UniqueID() then
			return v, v:Nick()
		end
	end
	return nil, 0
end

function XEN.TableHasValue( targ, val ) --Basically table.HasValue(), but that wasn't working so I made my own function.
	for k,v in pairs( targ ) do
		if k == val or v == val then
			return true, k
		end
	end
	return false, nil
end

function XEN.PrintAll( msg ) --MSG:STRING.
	umsg.Start( "PrintAll" )
		umsg.String( msg )
	umsg.End()
end

function XEN.PrintPlayer( ply, msg ) --PLY:PLAYER. MSG:STRING.
	umsg.Start( "PrintPlayer", ply )
		umsg.String( msg )
	umsg.End()
end

function XEN.PrintAdmin( msg ) --MSG:STRING.
	for k,v in pairs( player.GetAll() ) do
		if v:IsAdmin() then --This is for security.
			umsg.Start( "PrintAdmin", v )
				umsg.String( msg )
			umsg.End()
		end
	end
end

function XEN.ChatAll( msg, color ) --MSG:STRING. COLOR:VECTOR.
	umsg.Start( "ChatAll" )
		umsg.Vector( color )
		umsg.String( msg )
	umsg.End()
end

function XEN.ChatPlayer( ply, msg, color ) --PLY:PLAYER. MSG:STRING. COLOR:VECTOR.
	umsg.Start( "ChatPlayer", ply )
		umsg.Vector( color )
		umsg.String( msg )
	umsg.End()
end

function XEN.ChatAdmin( msg, color ) --MSG:STRING. COLOR:VECTOR.
	for k,v in pairs( player.GetAll() ) do
		if v:IsAdmin() then --For security.
			umsg.Start( "ChatAdmin", v )
				umsg.Vector( color )
				umsg.String( msg )
			umsg.End()
		end
	end
end